import { request } from "@/utils/http";
import { Key } from "react";
import type {
    ReqHospitalSetListParams,
  ReqHospitalSetListResponse,
  ReqAddHospitalParams,
  ReqUpdateHospitalParams,
  HospitalSetItem
  } from "./model/hospitalSetTypes";

// 获取医院列表
export const reqGetHospitalSetList = ({ page, limit, hosname, hoscode }:ReqHospitalSetListParams) => {
    return  request.get<any,ReqHospitalSetListResponse>(`/admin/hosp/hospitalSet/${page}/${limit}`, {
        params: {
          hosname,
          hoscode,
        },
      })
}

// 添加医院
export const reqAddHospital = (hospital: ReqAddHospitalParams) => {
  // 添加/更新/删除请求接口返回的响应数据的data属性为null
  return request.post<any, null>(`/admin/hosp/hospitalSet/save`, hospital);
};

// 根据id 获取医院的数据
export const reqUpdateHospital = (hospital: ReqUpdateHospitalParams) => {
  return request.put<any, null>(`/admin/hosp/hospitalSet/update`, hospital)
};
//  根据id 和 内容 修改数据
export const reqGetHospital = (id: number) => {
  return request.get<any,HospitalSetItem>(`/admin/hosp/hospitalSet/get/${id}`)
}

// 根据id 删除数据
export const reqRemoveHospital = (id: number) =>{
  return   request.delete <any,null>(`/admin/hosp/hospitalSet/remove/${id}`)
}

// 批量删除医院信息
export const reqBatchRemoveHospitalList = (idList: Key[]) => {
  return request.delete<any, null>(`/admin/hosp/hospitalSet/batchRemove`, {
    data:idList
  })
}